<?php
session_start();
require_once('../../include/function/config.function.php');
require_once('../../include/function/db.function.php');
require_once('../../include/function/autoload.function.php');
require_once('Log.php') ;

@$request = $_POST;

//参数有效性验证
//必填参数为空则出错

foreach( $request as $k => $v ){

	if ( empty( $v ) ){

		$_SESSION['errors'][$k] = true ;	
	}
}

if ( !empty($_SESSION['errors']) ){

	$_SESSION['errors']['message'] = 'Please enter the correct information in the highlighted fields:';
	header('Location:problem_add.php');
	exit ;
}

$PEAR_log = &Log::factory('file', 'soj.log', 'soj');  

try{
	$db = db_connect();
	$problem = new problem_process( $db , $request );
	$problem->save();

//	$_SESSION['errors'] = "Add success" ;
	header('Location:problem_add.php');
	exit ;

}catch(Exception $e){

	exception_handle( $e ) 

}
